#include <EObject.h>
#include <ObjectInspectorItem.h>

EObject::EObject(QObject *parent) : QObject(parent)
{
    m_objItem = new ObjectInspectorItem(this->objectName());
    m_objItem->setObjectPtr(QSharedPointer<EObject>(this));
    setEObjectName("newEobject");
}

EObject::~EObject()
{

}

ObjectInspectorItem *EObject::getObjItem()
{
    return m_objItem;
}

void EObject::refreshItemTest()
{
    m_objItem->setText(this->objectName());
}

QSharedPointer<EObject> EObject::getSharedPtr()
{
    return m_objItem->getObjectPtr();

}

void EObject::setEObjectName(const QString &name)
{
    setObjectName(name);
    m_objItem->setText(name);

}

QString EObject::getEObjectName()
{
    return objectName();
}

bool EObject::getShowInClassList()
{
    return m_showInClassList;
}

void EObject::copyFrom(EObject *objPtr)
{
    this->setEObjectName(objPtr->getEObjectName());
}

EObject *EObject::clone()
{
    EObject* newObj = new EObject();
    newObj->copyFrom(this);
    return newObj;
}

bool EObject::isTraverseChildEObject()
{
    return true;
}

void *EObject::getRelevantPtr()
{
    return NULL;
}

bool EObject::ifHasSuperClass(const QString &superClassTypeName)
{
    bool boolResult = false;
    const QMetaObject *metaobject = this->metaObject();
    const QMetaObject* current_object = metaobject;

    while (QString(current_object->className()) != "EObject")
    {
        if(QString(current_object->className()) == superClassTypeName)
        {
            boolResult = true;
            break;
        }
        current_object = current_object->superClass();
    }
    return boolResult;
}

bool EObject::isRecoverProperty(const QMetaProperty &property)
{
    QString propertyName(property.name());
    return m_recoverPropertyNameList.contains(propertyName);
}

void EObject::addRecoverPropertyName(const QString &propertyName)
{
    m_recoverPropertyNameList.push_back(propertyName);
}

QList<QString> EObject::getRecoverPropertyName()
{
    return m_recoverPropertyNameList;
}

void EObject::setShowInClassList(bool boolValue)
{
    m_showInClassList = boolValue;
}



//void EObject::setObjItem(ObjectInspectorItem *objItem)
//{
//    m_objItem = objItem;
//}

